package com.gameplatform.controller;

import com.gameplatform.common.response.BaseResponse;
import com.gameplatform.dto.LoginDTO;
import com.gameplatform.dto.RegisterDTO;
import com.gameplatform.entity.User;
import com.gameplatform.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/register")
    public BaseResponse<User> register(@RequestBody RegisterDTO registerDTO) {
        User user = userService.register(registerDTO);
        return BaseResponse.success(user, "注册成功");
    }

    @PostMapping("/login")
    public BaseResponse<Object> login(@RequestBody LoginDTO loginDTO) {
        Object result = userService.login(loginDTO);
        return BaseResponse.success(result, "登录成功");
    }

    @PostMapping("/logout")
    public BaseResponse<Void> logout() {
        return BaseResponse.success(null, "退出成功");
    }
} 